<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>查询快递</title>
    <link rel="stylesheet" href="/css/weui.min.css">
    <link rel="stylesheet" href="/css/express.css">
    <script src="/js/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>

<script type="text/javascript">

		$(document).ready(function () {
			
       		alert(location.href);
       		url=encodeURIComponent(location.href.split('#')[0]);
       		// url2=encodeURI(url);
       		alert(url);
       		$.get("/weixin/getticket?url="+url, function(data) {
       				data=eval("("+data+")");
       				wxConfigData["appId"]=data["appid"];
       				wxConfigData["timestamp"]=data["timestamp"];
       				wxConfigData["nonceStr"]=data["nonceStr"];
       				wxConfigData["signature"]=data["signature"];
       				// alert(wxConfigData);
       				wxInit ();
       			}
       		);
       		//alert(getUrlParam('openid'));
       });
       
       wxConfigData={
		    debug: false, //调试的时候最好设为true，它每一步都会alert数据出来，让你知道出了什么问题
		    appId: 'xxx',
		    timestamp: 1423367602, //随便填写一串数字
		    nonceStr: 'sMADlDUaGt6DsEc6', //随便一字符串
		    signature: '', //**这个要到服务器获取**
		    jsApiList: ['checkJsApi','scanQRCode'] 
		};
       // 初始化，已经获得签名
		function wxInit () {
		    // 配置参数
		    wx.config(wxConfigData);
		    
		    // 分享
		    wx.ready(function(){
			        wx.checkJsApi({  
			            jsApiList : ['scanQRCode'],  
			            success : function(res) {  
			        	}
		        	}); 
		  
		        //扫描二维码  
		    	document.querySelector('#scanQRCode').onclick = function() {  
		            wx.scanQRCode({  
		                needResult : 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，  
		                scanType : [ "qrCode", "barCode" ], // 可以指定扫二维码还是一维码，默认二者都有  
		                success : function(res) {  
		                    var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果  
		                    document.getElementById("id").value = result;//将扫描的结果赋予到jsp对应值上  
		                    alert("扫描成功::扫描码=" + result);  
		                }  
		            });  
		        };//end_document_scanQRCode  
		    });
		    wx.error(function(res){
		        alert("出错了：" + res.errMsg);  
		    });
		};    
       
       //获取请求链接的参数值
       function getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    		var r = window.location.search.substr(1).match(reg);
    		if (r != null) return unescape(r[2]); return null;
        }
       
       function my_submit(){
       		// alert("url="+location.href);
       		code_val=getUrlParam('code');
       		wldh_val=$("#id").val();
       		
       		alert("code="+code_val+wldh_val);
       		
       		$.get("/getdata",{code:code_val,wldh:wldh_val },function(data) {
       			window.location.href="/wuliuinfo?wldh="+wldh_val;
				//alert(openid_val + wldh_val);
	    	});
       }
       
</script>


<body>
	<div class="weui_cells weui_cells_form">
	  <div class="weui_cell">
	    <div class="weui_cell_bd"><label class="weui_label">物流单号</label></div>
	    <div class="weui_cell_bd weui_cell_primary">
	      <input id="id" class="weui_input" type="tel" placeholder="请输入物流单号">
	    </div>
	    <div class="weui_cell_bd weui_cell_primary">
	    	<button id="scanQRCode" >扫描二维码</button> 
	    </div>
	    <div class="weui_cell_bd weui_cell_primary">
	    	<a href="javascript:my_submit();" class="weui_btn weui_btn_primary">查询</a>
	    </div>
	  </div>
	</div>

</body></html>